package com.tsingteng.cosfun.utils;


import android.app.Activity;
import android.support.v4.app.Fragment;

import com.luck.picture.lib.PictureSelector;
import com.luck.picture.lib.config.PictureConfig;
import com.luck.picture.lib.config.PictureMimeType;
import com.luck.picture.lib.entity.LocalMedia;
import com.tsingteng.cosfun.R;
import com.tsingteng.cosfun.helper.VideoHelper;
import com.tsingteng.cosfun.helper.ViewHelper;
import com.tsingteng.cosfun.ui.message.uploadreportfragment.UploadReportFragment;

import java.util.ArrayList;
import java.util.List;

/**
 * 描述:
 * 创建人: 肖利
 * 时间: 2018/7/30
 * qq: (872179966)
 */

public class ImageViewUtils {
    /**
     * 跳转相册
     *
     * @param activity
     */
    public static void starPhoto(Activity activity, boolean isCamera) {
        PictureSelector.create(activity)
                .openGallery(PictureMimeType.ofImage())
                .maxSelectNum(1)
                .minSelectNum(1)
                .isCamera(isCamera)
                .forResult(PictureConfig.CHOOSE_REQUEST);

    }

    /**
     * 跳转相册视屏
     *
     * @param activity
     */
    public static void starVideo(Activity activity) {
        PictureSelector.create(activity)
                .openGallery(PictureMimeType.ofVideo())
                .maxSelectNum(1)
                .minSelectNum(1)
                .isCamera(false)
                .selectionMode(PictureConfig.SINGLE)
                .forResult(PictureConfig.TYPE_VIDEO);

    }

    /**
     * 跳转拍摄页面
     *
     * @param fragment
     */
    public static void starShoot(Fragment fragment, boolean isCamera) {
        PictureSelector.create(fragment)
                .openGallery(PictureMimeType.ofImage())
                .maxSelectNum(1)
                .minSelectNum(1)
                .isCamera(isCamera)
                .previewImage(false)
                .forResult(PictureConfig.CHOOSE_REQUEST);

    }

    /**
     * 预览大图
     *
     * @param activity
     * @param imagePath
     */
    public static void previewImage(Activity activity, String imagePath) {
        ArrayList<LocalMedia> list = new ArrayList<>();
        LocalMedia localMedia = new LocalMedia(imagePath, 0, 0, null);
        list.add(localMedia);
        PictureSelector.create(activity).themeStyle(R.style.picture_default_style).openExternalPreview(0, list);
    }

    /**
     * 预览大图
     *
     * @param fragment
     * @param imagePath
     */
    public static void previewImage(Fragment fragment, String imagePath) {
        ArrayList<LocalMedia> list = new ArrayList<>();
        LocalMedia localMedia = new LocalMedia(imagePath, 0, 0, null);
        list.add(localMedia);
        PictureSelector.create(fragment).themeStyle(R.style.picture_default_style).openExternalPreview(0, list);
    }
}
